<template>
  <div>
    <h1>招标文件查看</h1>
    <ClTable
      v-if="loaded"
      :table-data="getBidFileInfo"
      :show-page="false"
      :show-search="false"
      :column-list="columnList"
      :filter-form-item="filterFormItem"
    >
      <template #column>
        <el-table-column label="操作" width="250">
          <template #default="{ row }">
            <el-button v-if="row.viewButton" link type="primary" @click="handleOpen(row.viewPath)">查看</el-button>
            <el-button v-if="row.downloadPath" link type="primary" @click="handleOpen(row.downloadPath)">
              下载
            </el-button>
          </template>
        </el-table-column>
      </template>
    </ClTable>
  </div>
</template>

<script setup lang="ts">
import { getBidFileInfo } from '@/api/invite-tenders-file-view'
import { useProjectInfoStore } from '@/store/projectInfo'
const { projectInfo } = useProjectInfoStore()

const columnList = ref([
  {
    label: '文件名称',
    prop: 'fileName'
  }
])
const filterFormItem = ref([
  {
    key: 'projectNumber',
    value: '',
    name: '',
    formType: 'empty',
    verificationData: '',
    elementConfig: {}
  }
])
const handleOpen = (row: any) => {
  window.open(row, '_blank')
}

onMounted(() => {
  getTableData()
})
const loaded = ref(false)
const getTableData = () => {
  loaded.value = false
  filterFormItem.value[0].value = projectInfo.projectNumber
  loaded.value = true
}
</script>
